package com.gticket.customerbackend.mapper;

import com.gticket.customerbackend.pojo.Level;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface LevelMapper {
  /**
   * 查询所有vip等级信息
   * @return
   */
  @Select("select * from ${database}.levels where flag=0")
  List<Level> listLevels(Level level);

  /**
   * 新增vip等级
   * @param level
   */
  @Insert("insert into ${database}.levels(level_name,min_score,max_score,discount) values(#{level_name},#{min_score},#{max_score},#{discount})")
  void insertLevel(Level level);

  /**
   * 修改vip信息
   * @param level
   */
  @Update("update ${database}.levels set  level_name=#{level_name},min_score=#{min_score},max_score=#{max_score},discount=#{discount} where level_id=#{level_id}")
  void updateLevel(Level level);

  /**
   * 进行软删除
   * @param level
   */
  @Update("update ${database}.levels set flag=1 where level_id=#{level_id}")
  void deleteLevel(Level level);



}
